-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Category list helpers #25777
Category list helpers #25777
Conversation
…ture/24463-category-helpers
…ture/24463-category-helpers
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
…ture/24463-category-helpers
…ture/24463-category-helpers
A few important commits have been pushed. |
src/CONST.js
Outdated
@@ -2591,6 +2591,9 @@ const CONST = { | |||
NAVIGATE: 'NAVIGATE', | |||
}, | |||
}, | |||
INDENTS: ' ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can use
's here or would those automatically be escaped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a way to use String.fromCharCode(160)
, it looks like:
INDENTS: String.fromCharCode(160) + String.fromCharCode(160) + String.fromCharCode(160) + String.fromCharCode(160),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like spaces better than that haha
…ture/24463-category-helpers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rezkiy37 please add video at least on web
Based on goals for this PR, nothing to test here in the app. Automated test is fine I think. |
I'm not lazy, I just do not know what to record for this PR. This code will work only in a scope of next PR, where I am adding UI/UX. |
sure thing. so I updated comment - #25777 (comment) |
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, nice work! Just a NAB comment from me 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some small comments.
Tests are great!
src/libs/OptionsListUtils.js
Outdated
* @param {Boolean} [isOneLine] - a flag to determine if text should be one line | ||
* @returns {Array<Object>} | ||
*/ | ||
function getOptionTree(options, isOneLine = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this function be used for anything other than categories? If not, perhaps we could make the function name more specific. Like getCategoryOptionTree
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Done!
src/libs/OptionsListUtils.js
Outdated
@@ -587,6 +587,138 @@ function isCurrentUser(userDetails) { | |||
return _.some(_.keys(loginList), (login) => login.toLowerCase() === userDetailsLogin.toLowerCase()); | |||
} | |||
|
|||
/** | |||
* Build the options for the tree hierarchy via indents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Build the options for the tree hierarchy via indents | |
* Build the options for the category tree hierarchy via indents |
NAB: just a little bit more specific since I think this is only used for categories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Done!
src/libs/OptionsListUtils.js
Outdated
const searchCategories = _.filter(categories, (category) => category.name.toLowerCase().includes(searchInputValue.toLowerCase())); | ||
|
||
categorySections.push({ | ||
title: '', // Search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this comment mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments mean which section we push. There are cases when no visible title. Anyway, I've tried to improve the comments. Please check.
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/yuwenmemon in version: 1.3.61-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.61-3 🚀
|
* @param {Boolean} [isOneLine] - a flag to determine if text should be one line | ||
* @returns {Array<Object>} | ||
*/ | ||
function getCategoryOptionTree(options, isOneLine = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #29281
This operator didn't order the sub-categories correctly
keyForList: optionName, | ||
searchText: array.slice(0, index + 1).join(CONST.PARENT_CHILD_SEPARATOR), | ||
tooltipText: optionName, | ||
isDisabled: isChild ? !option.enabled : true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rezkiy37 I wonder why do we need to check isChild
here? Can you help explain when you have a chance? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as you can see above there is a definition for isChild
- = array.length - 1 === index
. So for example there is an option parent:child
. It automatically sets isDisabled
as true
for parent
. However, it checks option.enabled
for child
. Because only child
is an option that can be disabled or enabled. parent
is an option that can be disabled with this example. To enable parent
the app should have a specific parent
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY for your explanation. That makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(BugZero Checklist) Coming from #42936, We ended up modifying the isDisabled
condion to have hover effect over selected parent category in the list
Details
This is the second PR of four for the issue. Goals for this PR:
getOptionTree
function, to format the parent sections we'll need to utilize a helper method to transform the "Parent: Child" category format into a format that is easier to interpret.getOptions
function, to split categories by sections.getNewChatOptions
function, to filter the options using the function.Fixed Issues
$ #24463
PROPOSAL: N/A
Tests
Since, the PR does not reflect on any existing flow, it does not require any actions with the app to verify. Basically, everything should work as it is in the production. Also, there are many tests for these changes.
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android